package com.example.rlw.mvpplugintest.home;

import com.example.rlw.mvpplugintest.bean.UserBean;
import com.example.rlw.mvpplugintest.mvp.BaseObserver;
import com.example.rlw.mvpplugintest.mvp.BasePresenterImpl;
import com.example.rlw.mvpplugintest.mvp.MyObservableTransformer;
import com.example.rlw.mvpplugintest.net.HttpResponseData;
import com.example.rlw.mvpplugintest.net.HttpService;
import com.example.rlw.mvpplugintest.net.NetWorks;

import java.util.List;

/**
 * MVPPlugin
 * 邮箱 784787081@qq.com
 */

public class HomePresenter extends BasePresenterImpl<HomeContract.View> implements HomeContract.Presenter {

    @Override
    public void getData(String userName, String userPwd) {
        NetWorks.configRetrofit(HttpService.class)
                .getData(userName, userPwd)
                .compose(new MyObservableTransformer<HttpResponseData<List<UserBean>>>())
                .subscribe(new BaseObserver<List<UserBean>>(getView(), this) {
                    @Override
                    public void onSuccess(List<UserBean> data) {
                        getView().onSuccess(data);
                    }
                });
    }
}
